<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html >
<html>
<head>
<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
<script src="<%=contextPath%>/static/common/diytemplate.js"></script>
</head>
<body style="background-color: white;" class="gray-bg">
	<div class="ibox-content">
		<form class="form-horizontal m-t" id="signupForm" method="post" enctype="multipart/form-data">
			<div class="form-group" >
				<label class="col-sm-3 control-label">模版名称：</label>
				<div class="col-sm-8">
					<input type="hidden" name="id" value="${template.id }">
					<input type="hidden" name="jsondatas.id" value="${template.jsondatas.id }">
					<input type="text" class="form-control" id="name"  name="name" value="${template.name }" />
			  </div>
			</div>
			<input type="hidden" id="type" name="type" value="${template.type }">
			<%-- <%@ include file="/WEB-INF/view/common/iftemplate.jsp"%> --%>
			<%@ include file="/WEB-INF/view/common/diytemplate.jsp"%>
			<div class="form-group" style="text-align: center;">
				<div class="col-sm-8 col-sm-offset-3">
					<button class="btn btn-primary" type="button" id="sub">提交</button>
				</div>
			</div>
		</form>
	</div>


	<script>
    $(function () {
    	var dataStr = ${template.jsondatas.jsondata };
    	/*加载所有自定义列 */
    	updatepageinitterm(dataStr);
        $("#sub").click(function () {
        	if(!inputIsNull()){
				return;
			}
            $("#signupForm").ajaxSubmit({
                url: '<%=contextPath%>/template/update',
                type: 'post',
                dataType: "json",
                success: function (data) {
                    if (data.code == 200) {
                        swal({
                            title: data.message,
                            type: "success",
                            showCancelButton: false,
                            confirmButtonText: "确定",
                            animation: "slide-from-bottom",
                            closeOnConfirm: true
                        }, function () {
                            top.Dialog.close();
                        });
                    } else {
                        swal("错误", data.message, "error");
                    }
                }
            });

        });
    });
    
</script>
</body>
</html>